// Package sys
// @Link  https://github.com/bufanyun/hotgo
// @Copyright  Copyright (c) 2025 HotGo CLI
// @Author  Ms <133814250@qq.com>
// @License  https://github.com/bufanyun/hotgo/blob/master/LICENSE
// @AutoGenerate Version 2.15.11
package sys

import (
	"context"
	"hotgo/api/admin/productnew"
	"hotgo/internal/model/input/sysin"
	"hotgo/internal/service"
)

var (
	ProductNew = cProductNew{}
)

type cProductNew struct{}

// List 查看新人有礼活动列表
func (c *cProductNew) List(ctx context.Context, req *productnew.ListReq) (res *productnew.ListRes, err error) {
	list, totalCount, err := service.SysProductNew().List(ctx, &req.ProductNewListInp)
	if err != nil {
		return
	}

	if list == nil {
		list = []*sysin.ProductNewListModel{}
	}

	res = new(productnew.ListRes)
	res.List = list
	res.PageRes.Pack(req, totalCount)
	return
}

// Edit 更新新人有礼活动
func (c *cProductNew) Edit(ctx context.Context, req *productnew.EditReq) (res *productnew.EditRes, err error) {
	err = service.SysProductNew().Edit(ctx, &req.ProductNewEditInp)
	return
}

// View 获取指定新人有礼活动信息
func (c *cProductNew) View(ctx context.Context, req *productnew.ViewReq) (res *productnew.ViewRes, err error) {
	data, err := service.SysProductNew().View(ctx, &req.ProductNewViewInp)
	if err != nil {
		return
	}

	res = new(productnew.ViewRes)
	res.ProductNewViewModel = data
	return
}

// Status 更新新人有礼活动状态
func (c *cProductNew) Status(ctx context.Context, req *productnew.StatusReq) (res *productnew.StatusRes, err error) {
	err = service.SysProductNew().Status(ctx, &req.ProductNewStatusInp)
	return
}
